package com.kaizeli.website.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Knife4j配置类
 */
@Configuration
public class Knife4jConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("凯泽利项目管理系统API")
                        .version("1.0.0")
                        .description("凯泽利项目管理系统 - 验收审核功能API文档\n\n" +
                                "**认证说明：**\n" +
                                "- 部分接口需要Token认证（标记为🔒的接口）\n" +
                                "- 请先调用 `/api/user/login` 登录获取Token\n" +
                                "- 点击右上角 \"Authorize\" 按钮，输入Token（无需Bearer前缀）\n" +
                                "- 或在请求头中添加：`Authorization: Bearer YOUR_TOKEN`")
                        .contact(new Contact()
                                .name("凯泽利团队")
                                .email("support@kaizeli.com"))
                        .license(new License()
                                .name("MIT License")
                                .url("https://opensource.org/licenses/MIT")))
                .externalDocs(new ExternalDocumentation()
                        .description("项目说明文档")
                        .url("http://localhost:8086"))
                .components(new Components()
                        .addSecuritySchemes("Bearer Authentication",
                                new SecurityScheme()
                                        .type(SecurityScheme.Type.HTTP)
                                        .scheme("bearer")
                                        .bearerFormat("JWT")
                                        .description("请输入JWT Token（登录后获取）")));
    }
}

